import { ChangeDetectorRef, Component, OnInit, ViewChild } from '@angular/core';
import { TaskService } from '../../../services/task.service';

@Component({
  selector: 'm-step-3',
  templateUrl: './step-3.component.html',
  styleUrls: ['../add.component.scss'],
})
export class Step3Component implements OnInit {
  architectureModel = "";
  packageModel= "" ;
  architecture = [] ;
  packages = [];
  constructor(private taskManager: TaskService,){

  }
  change(){
    this.getPakeages(this.architectureModel)
  }
  async getPakeages(acch){
    let packages:any = await this.taskManager.getAddOptions(acch)
    if(packages.code == 0 && packages.message.package_name &&packages.message.package_name.length){
      this.packages = packages.message.package_name ;
      this.packageModel = this.packages[0] 
    }
  }
  ngOnInit() {
    this.taskManager.getAddOptions().then((res:any)=>{
      const { architecture  } = res.message ; 
      if( architecture && architecture.length){
        this.architecture = architecture ;
        this.architectureModel = architecture[0]
        this.getPakeages(this.architectureModel)
      }
      
    })
  }

}
